<%@ page contentType="text/html; charset=utf-8"%>
<%@include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<%-- ueditor	--%>
	<script type="text/javascript">
		window.UEDITOR_HOME_URL = '${base}/ueditor/',ueditor_loader={};;
	</script>
	<script type="text/javascript" charset="utf-8" src="${base }/ueditor/editor_config.js"></script>
	<script type="text/javascript" charset="utf-8" src="${base }/ueditor/editor_all.js"></script>
	<link rel="stylesheet" type="text/css" href="${base }/ueditor/themes/default/ueditor.css"/>
	
	<title>编辑文章内容</title>
	
	
	<script type="text/javascript">
		$(document).ready(function(){
			var path = '${pageContext.request.contextPath}';
			
		});
		function deleteAccessory(id,storename){
			if(window.confirm('确定要删除该附件吗？')){
				$.ajax({
					type: "post",
					url: "${pageContext.request.contextPath }/upload/deletefile.shtml",
					data: "number="+id+"&filename="+storename+"&type=0",
					success: function(){
						$("input[value='"+storename+"']").parent().remove();
					}
				});
			}
		}
		function onUploadStart() {
			$(":button").prop("disabled", true);
		}
		function onQueueComplete() {//上传队列全部完成后执行的方法		
			$(":button").prop("disabled", false);
		}
		function onUploadSuccess(file,data,response) {
			alert(data);
			var json = $.parseJSON(data);
			if(data == ''){
				alert('上传失败');
			}if(json.detailMessage){
				alert(json.detailMessage);
			}else{
				var html = "<div>"; 
				html += "<input type=\"hidden\" name=\"accessoryid\" value=\""+json.sysfilename+"\"  /><span style=\"color:red;font-size:12px;width:330px\">"+json.sysfilename+"</span><img style=\"cursor: hand\"  onclick=\"deleteAccessory('-1','"+json.sysfilename+"')\"  src=\""+path+"/script/jquery/uploadify/cancel.png\"/>";
				html += "</div>";
				$("#accessory").append(html);
				alert($("#accessory").html());
	
			}
		}
		
		function editorSyn(ename){
			$.each(ueditor_loader[ename],function(i){
				this.sync(); 
			});
		}
  	</script>
</head>


<body>

<div >
	<form action="${ctx }/admin/articleinfo/editArticleInfo.shtml" method="post" onsubmit="editorSyn('test');return validateCallback(this, navTabAjaxDone);"> 
		<div >
		<input type="hidden" name="id" value="${obj.id}"/>
		标题：<input type="text" name="title" value="${obj.title}"/><br/> 
		内容：<textarea name="content" id="content" class="editor"  module="test">${obj.content}</textarea>
		<input type="file" id="file_upload" name="file_upload" />
		</div>
		<c:forEach var="ai" items="${obj.attachments}">
        	<li><a href="${base}/upload/getArticleatts.shtml?id=${ai.id}&t=1&file=${ai.newname}">${ai.newname}</a></li>
        </c:forEach>
		<div id="accessory">附件</div>
		<div class="formBar">
			<ul>
				<li>
					<div class="buttonActive"><div class="buttonContent"><button type="submit">保存</button></div></div>
				</li>
         		<li>
               		<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
		 	</ul>
		</div>


	</form>	
</div>
</body>
</html>